import huck
import huck.ext.session_beaker

class MainPage(huck.RequestHandler):
  def get(self):
    count = self.session.get('count', 0)

    self.response.out.write('<html><body>')
    self.response.out.write('Count: %s' % count)
    self.response.out.write('</body></html>')

    self.session.set('count', count + 1)
    self.session.save()

# Setup application
url_mapping = [('/', MainPage),]
application = huck.Application(url_mapping, debug=True)

# Setup session
session = huck.ext.session_beaker.Create()
application = session.setup(application)

if __name__ == '__main__':
  huck.run_dev('', 8080, application)
